extends "../cTDZ_3/cTDZ_3.gd"
func _info():
	pass

func _connect():
	._connect()
	
func _extInit():
	._extInit()
	chaName = "娜迦牧师"
	lv = 2
	attCoe.atk = 20 / 8.5 * 2 / 2
	attCoe.maxHp = 650 / 112.5 / 2
	addCdSkill("njms",8)
	addSkillTxt("水之棱镜：为自己和生命值最低的队友附加1块棱镜，反弹50%伤害【特效伤害除外;无法多次附加；附加后可反弹2次伤害，之后每5秒恢复1次】[cd:8秒]")

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "njms":
		cst("水之棱镜","000000",position)
		var chas = getAllChas(2)
		chas.sort_custom(self,"sort")
		for i in chas:
			if i == self:continue
			if i.hasBuff("b_szlj"):break
			i.addBuff(BF2.new(1))
			break
		if hasBuff("b_szlj"):return
		addBuff(BF2.new(1))

func sort(a,b):
	return a.att.hp < b.att.hp

class BF2:
	extends Buff
	var cnt = 2
	var tcnt = 0
	func _init(lv):
		attInit()
		id = "b_szlj"

	func _connect():
		masCha.connect("onHurt",self,"run")
		tcnt = 0
	func run(atkinfo):
		if !atkinfo.isMiss && atkinfo.atkType != Chara.AtkType.EFF && cnt:
			atkinfo.hurtVal *= 0.5
			masCha.hurtChara(atkinfo.atkCha,atkinfo.hurtVal,atkinfo.hurtType,Chara.AtkType.EFF)
			cnt -= 1
			
	func _upS():
		tcnt += 1
		if tcnt % 5 == 0:
			tcnt = 0
			cnt += 1
